home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume34 / imagemagick / patch02 < prev    next >
Encoding:
Text File  |  1992-12-27  |  13.5 KB  |  488 lines

  1. Newsgroups: comp.sources.misc
  2. From: cristy@eplrx7.es.duPont.com (John Cristy)
  3. Subject: v34i088: imagemagick - X11 image processing and display v2.2, Patch02
  4. Message-ID: <1992Dec27.232211.1662@sparky.imd.sterling.com>
  5. X-Md4-Signature: 302b92355d1dae52f6f0df17254be26e
  6. Date: Sun, 27 Dec 1992 23:22:11 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: cristy@eplrx7.es.duPont.com (John Cristy)
  10. Posting-number: Volume 34, Issue 88
  11. Archive-name: imagemagick/patch02
  12. Environment: UNIX, VMS, X11, SGI, DEC, Cray, Sun, Vax
  13. Patch-To: imagemagick: Volume 34, Issue 28-54
  14.  
  15.                     ImageMagick 2.2 Patch #2
  16.  
  17. To apply this patch:
  18.  
  19. cd to the top of the source tree (to the directory containing the
  20. "ImageMagick" subdirectories) and do:
  21.  
  22.   patch -p < ThisFile
  23.  
  24. Prereq: ImageMagick 2.2.1 (posted from comp.sources.misc, Volume 34,
  25. Issue 28 + Patch 1).
  26.  
  27. Alternatively get the entire distribution as contrib/ImageMagick.tar.Z
  28. on export.lcs.mit.edu.  I will post this patch to comp.sources.misc in
  29. a few days.
  30. ------------------
  31. #! /bin/sh
  32. # This is a shell archive.  Remove anything before this line, then feed it
  33. # into a shell via "sh file" or similar.  To overwrite existing files,
  34. # type "sh file -c".
  35. # Contents:  fix-02
  36. # Wrapped by kent@sparky on Sun Dec 27 17:17:45 1992
  37. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
  38. echo If this archive is complete, you will see the following message:
  39. echo '          "shar: End of archive."'
  40. if test -f 'fix-02' -a "${1}" != "-c" ; then 
  41.   echo shar: Will not clobber existing file \"'fix-02'\"
  42. else
  43.   echo shar: Extracting \"'fix-02'\" \(11479 characters\)
  44.   sed "s/^X//" >'fix-02' <<'END_OF_FILE'
  45. Xdiff -r -c ImageMagick/ChangeLog ImageMagick2.2.2/ChangeLog
  46. X*** ImageMagick/ChangeLog    Mon Dec 21 14:12:35 1992
  47. X--- ImageMagick2.2.2/ChangeLog    Tue Dec 22 16:07:20 1992
  48. X***************
  49. X*** 1,3 ****
  50. X--- 1,14 ----
  51. X+ ImageMagick 2.2.2
  52. X+ 
  53. X+   o Dithering did not work properly on the Cray (due to right shift problem).
  54. X+ 
  55. X+   o In most cases dithering requires 1/2 as much memory as previously.
  56. X+ 
  57. X+   o Dithering was sped up by ~15%.
  58. X+ 
  59. X+   o Occasionally the quantization error was reported incorrectly.
  60. X+ 
  61. X+ 
  62. X  ImageMagick 2.2.1
  63. X  
  64. X    o The number of colors reported with the -verbose option was on
  65. Xdiff -r -c ImageMagick/X.c ImageMagick2.2.2/X.c
  66. X*** ImageMagick/X.c    Mon Dec 21 14:12:34 1992
  67. X--- ImageMagick2.2.2/X.c    Tue Dec 22 16:06:18 1992
  68. X***************
  69. X*** 1283,1291 ****
  70. X    /*
  71. X      Initialize annotated image.
  72. X    */
  73. X!   if (image->packets != (image->columns*image->rows))
  74. X!     if (!UncompressImage(image))
  75. X!       return(False);
  76. X    /*
  77. X      Initialize annotated pixmap.
  78. X    */
  79. X--- 1283,1290 ----
  80. X    /*
  81. X      Initialize annotated image.
  82. X    */
  83. X!   if (!UncompressImage(image))
  84. X!     return(False);
  85. X    /*
  86. X      Initialize annotated pixmap.
  87. X    */
  88. Xdiff -r -c ImageMagick/display.h ImageMagick2.2.2/display.h
  89. X*** ImageMagick/display.h    Tue Dec 22 16:23:13 1992
  90. X--- ImageMagick2.2.2/display.h    Tue Dec 22 16:23:32 1992
  91. X***************
  92. X*** 51,55 ****
  93. X  */
  94. X  #ifndef lint
  95. X  static char 
  96. X!   Version[]="@(#)ImageMagick 2.2.1 92/12/10 cristy@dupont.com";
  97. X  #endif
  98. X--- 51,55 ----
  99. X  */
  100. X  #ifndef lint
  101. X  static char 
  102. X!   Version[]="@(#)ImageMagick 2.2.2 92/12/22 cristy@dupont.com";
  103. X  #endif
  104. Xdiff -r -c ImageMagick/image.c ImageMagick2.2.2/image.c
  105. X*** ImageMagick/image.c    Fri Dec 18 17:07:28 1992
  106. X--- ImageMagick2.2.2/image.c    Tue Dec 22 16:06:19 1992
  107. X***************
  108. X*** 731,739 ****
  109. X    /*
  110. X      Image must be uncompressed.
  111. X    */
  112. X!   if (image->packets != (image->columns*image->rows))
  113. X!     if (!UncompressImage(image))
  114. X!       return;
  115. X    if (!image->alpha)
  116. X      {
  117. X        /*
  118. X--- 731,738 ----
  119. X    /*
  120. X      Image must be uncompressed.
  121. X    */
  122. X!   if (!UncompressImage(image))
  123. X!     return;
  124. X    if (!image->alpha)
  125. X      {
  126. X        /*
  127. X***************
  128. X*** 5190,5195 ****
  129. X--- 5189,5196 ----
  130. X    RunlengthPacket
  131. X      *uncompressed_pixels;
  132. X  
  133. X+   if (image->packets == (image->columns*image->rows))
  134. X+     return(True);
  135. X    /*
  136. X      Uncompress runlength-encoded packets.
  137. X    */
  138. XCommon subdirectories: ImageMagick/images and ImageMagick2.2.2/images
  139. Xdiff -r -c ImageMagick/quantize.c ImageMagick2.2.2/quantize.c
  140. X*** ImageMagick/quantize.c    Mon Dec 21 11:12:00 1992
  141. X--- ImageMagick2.2.2/quantize.c    Tue Dec 22 16:06:18 1992
  142. X***************
  143. X*** 745,753 ****
  144. X        blue;
  145. X    } ScaledColorPacket;
  146. X  
  147. X-   Image
  148. X-     *dithered_image;
  149. X- 
  150. X    int
  151. X      *cache,
  152. X      odd_scanline;
  153. X--- 745,750 ----
  154. X***************
  155. X*** 769,786 ****
  156. X      *cs,
  157. X      *ns;
  158. X  
  159. X    register unsigned int
  160. X      id;
  161. X  
  162. X-   register unsigned short
  163. X-     index;
  164. X- 
  165. X    ScaledColorPacket
  166. X      *scanline;
  167. X  
  168. X    unsigned char
  169. X!     *range_limit,
  170. X!     *range_table;
  171. X  
  172. X    unsigned int
  173. X      i,
  174. X--- 766,785 ----
  175. X      *cs,
  176. X      *ns;
  177. X  
  178. X+   register unsigned char
  179. X+     *range_limit;
  180. X+ 
  181. X    register unsigned int
  182. X      id;
  183. X  
  184. X    ScaledColorPacket
  185. X      *scanline;
  186. X  
  187. X    unsigned char
  188. X!     blue,
  189. X!     green,
  190. X!     *range_table,
  191. X!     red;
  192. X  
  193. X    unsigned int
  194. X      i,
  195. X***************
  196. X*** 787,803 ****
  197. X      x,
  198. X      y;
  199. X  
  200. X    /*
  201. X!     Initialize dithered image attributes.
  202. X    */
  203. X!   image->orphan=True;
  204. X!   dithered_image=CopyImage(image,image->columns,image->rows,False);
  205. X!   image->orphan=False;
  206. X!   if (dithered_image == (Image *) NULL)
  207. X!     {
  208. X!       Warning("unable to dither image","memory allocation failed");
  209. X!       return(True);
  210. X!     }
  211. X    /*
  212. X      Allocate the cache & scanline buffers to keep track of quantization error.
  213. X    */
  214. X--- 786,800 ----
  215. X      x,
  216. X      y;
  217. X  
  218. X+   unsigned short
  219. X+     index;
  220. X+ 
  221. X    /*
  222. X!     Image must be uncompressed.
  223. X    */
  224. X!   if (!UncompressImage(image))
  225. X!     return(True);
  226. X!   image->compression=NoCompression;
  227. X    /*
  228. X      Allocate the cache & scanline buffers to keep track of quantization error.
  229. X    */
  230. X***************
  231. X*** 827,846 ****
  232. X      Preload first scanline.
  233. X    */
  234. X    p=image->pixels;
  235. X-   image->runlength=p->length+1;
  236. X    cs=scanline+1;
  237. X    for (i=0; i < image->columns; i++)
  238. X    {
  239. X-     if (image->runlength > 0)
  240. X-       image->runlength--;
  241. X-     else
  242. X-       {
  243. X-         p++;
  244. X-         image->runlength=p->length;
  245. X-       }
  246. X      cs->red=p->red;
  247. X      cs->green=p->green;
  248. X      cs->blue=p->blue;
  249. X      cs++;
  250. X    }
  251. X    odd_scanline=False;
  252. X--- 824,836 ----
  253. X      Preload first scanline.
  254. X    */
  255. X    p=image->pixels;
  256. X    cs=scanline+1;
  257. X    for (i=0; i < image->columns; i++)
  258. X    {
  259. X      cs->red=p->red;
  260. X      cs->green=p->green;
  261. X      cs->blue=p->blue;
  262. X+     p++;
  263. X      cs++;
  264. X    }
  265. X    odd_scanline=False;
  266. X***************
  267. X*** 856,871 ****
  268. X            ns+=(image->columns+2);
  269. X          for (i=0; i < image->columns; i++)
  270. X          {
  271. X-           if (image->runlength > 0)
  272. X-             image->runlength--;
  273. X-           else
  274. X-             {
  275. X-               p++;
  276. X-               image->runlength=p->length;
  277. X-             }
  278. X            ns->red=p->red;
  279. X            ns->green=p->green;
  280. X            ns->blue=p->blue;
  281. X            ns++;
  282. X          }
  283. X        }
  284. X--- 846,855 ----
  285. X            ns+=(image->columns+2);
  286. X          for (i=0; i < image->columns; i++)
  287. X          {
  288. X            ns->red=p->red;
  289. X            ns->green=p->green;
  290. X            ns->blue=p->blue;
  291. X+           p++;
  292. X            ns++;
  293. X          }
  294. X        }
  295. X***************
  296. X*** 874,880 ****
  297. X          /*
  298. X            Distribute error left-to-right for even scanlines.
  299. X          */
  300. X!         q=dithered_image->pixels+image->columns*y;
  301. X          cs=scanline+1;
  302. X          ns=scanline+(image->columns+2)+1;
  303. X          step=1;
  304. X--- 858,864 ----
  305. X          /*
  306. X            Distribute error left-to-right for even scanlines.
  307. X          */
  308. X!         q=image->pixels+image->columns*y;
  309. X          cs=scanline+1;
  310. X          ns=scanline+(image->columns+2)+1;
  311. X          step=1;
  312. X***************
  313. X*** 884,890 ****
  314. X          /*
  315. X            Distribute error right-to-left for odd scanlines.
  316. X          */
  317. X!         q=dithered_image->pixels+image->columns*y+(image->columns-1);
  318. X          cs=scanline+(image->columns+2)+(image->columns-1)+1;
  319. X          ns=scanline+(image->columns-1)+1;
  320. X          step=(-1);
  321. X--- 868,874 ----
  322. X          /*
  323. X            Distribute error right-to-left for odd scanlines.
  324. X          */
  325. X!         q=image->pixels+image->columns*y+(image->columns-1);
  326. X          cs=scanline+(image->columns+2)+(image->columns-1)+1;
  327. X          ns=scanline+(image->columns-1)+1;
  328. X          step=(-1);
  329. X***************
  330. X*** 891,900 ****
  331. X        }
  332. X      for (x=0; x < image->columns; x++)
  333. X      {
  334. X!       q->red=range_limit[cs->red];
  335. X!       q->green=range_limit[cs->green];
  336. X!       q->blue=range_limit[cs->blue];
  337. X!       i=(q->red >> 2) << 12 | (q->green >> 2) << 6 | q->blue >> 2;
  338. X        if (cache[i] < 0)
  339. X          {
  340. X            /*
  341. X--- 875,884 ----
  342. X        }
  343. X      for (x=0; x < image->columns; x++)
  344. X      {
  345. X!       red=range_limit[cs->red];
  346. X!       green=range_limit[cs->green];
  347. X!       blue=range_limit[cs->blue];
  348. X!       i=(red >> 2) << 12 | (green >> 2) << 6 | blue >> 2;
  349. X        if (cache[i] < 0)
  350. X          {
  351. X            /*
  352. X***************
  353. X*** 903,911 ****
  354. X            node=cube.root;
  355. X            for ( ; ; )
  356. X            {
  357. X!             id=(q->red > node->mid_red ? 1 : 0) |
  358. X!               (q->green > node->mid_green ? 1 : 0) << 1 |
  359. X!               (q->blue > node->mid_blue ? 1 : 0) << 2;
  360. X              if ((node->children & (1 << id)) == 0)
  361. X                break;
  362. X              node=node->child[id];
  363. X--- 887,895 ----
  364. X            node=cube.root;
  365. X            for ( ; ; )
  366. X            {
  367. X!             id=(red > node->mid_red ? 1 : 0) |
  368. X!               (green > node->mid_green ? 1 : 0) << 1 |
  369. X!               (blue > node->mid_blue ? 1 : 0) << 2;
  370. X              if ((node->children & (1 << id)) == 0)
  371. X                break;
  372. X              node=node->child[id];
  373. X***************
  374. X*** 913,931 ****
  375. X            /*
  376. X              Find closest color among siblings and their children.
  377. X            */
  378. X!           cube.color.red=q->red;
  379. X!           cube.color.green=q->green;
  380. X!           cube.color.blue=q->blue;
  381. X            cube.distance=(~0);
  382. X            ClosestColor(node->parent);
  383. X            cache[i]=cube.color_number;
  384. X          }
  385. X        index=(unsigned short) cache[i];
  386. X!       red_error=(int) q->red-(int) cube.colormap[index].red;
  387. X!       green_error=(int) q->green-(int) cube.colormap[index].green;
  388. X!       blue_error=(int) q->blue-(int) cube.colormap[index].blue;
  389. X        q->index=index;
  390. X-       q->length=0;
  391. X        q+=step;
  392. X        /*
  393. X          Propagate the error in these proportions:
  394. X--- 897,914 ----
  395. X            /*
  396. X              Find closest color among siblings and their children.
  397. X            */
  398. X!           cube.color.red=red;
  399. X!           cube.color.green=green;
  400. X!           cube.color.blue=blue;
  401. X            cube.distance=(~0);
  402. X            ClosestColor(node->parent);
  403. X            cache[i]=cube.color_number;
  404. X          }
  405. X        index=(unsigned short) cache[i];
  406. X!       red_error=(int) red-(int) cube.colormap[index].red;
  407. X!       green_error=(int) green-(int) cube.colormap[index].green;
  408. X!       blue_error=(int) blue-(int) cube.colormap[index].blue;
  409. X        q->index=index;
  410. X        q+=step;
  411. X        /*
  412. X          Propagate the error in these proportions:
  413. X***************
  414. X*** 933,953 ****
  415. X            3/16  5/16  1/16
  416. X        */
  417. X        cs+=step;
  418. X!       cs->red+=red_error-((red_error*9+8) >> 4);
  419. X!       cs->green+=green_error-((green_error*9+8) >> 4);
  420. X!       cs->blue+=blue_error-((blue_error*9+8) >> 4);
  421. X        ns-=step;
  422. X!       ns->red+=(red_error*3+8) >> 4;
  423. X!       ns->green+=(green_error*3+8) >> 4;
  424. X!       ns->blue+=(blue_error*3+8) >> 4;
  425. X        ns+=step;
  426. X!       ns->red+=(red_error*5+8) >> 4;
  427. X!       ns->green+=(green_error*5+8) >> 4;
  428. X!       ns->blue+=(blue_error*5+8) >> 4;
  429. X        ns+=step;
  430. X!       ns->red+=(red_error+8) >> 4;
  431. X!       ns->green+=(green_error+8) >> 4;
  432. X!       ns->blue+=(blue_error+8) >> 4;
  433. X      }
  434. X      odd_scanline=!odd_scanline;
  435. X    }
  436. X--- 916,936 ----
  437. X            3/16  5/16  1/16
  438. X        */
  439. X        cs+=step;
  440. X!       cs->red+=(red_error-((red_error*9+8)/16));
  441. X!       cs->green+=(green_error-((green_error*9+8)/16));
  442. X!       cs->blue+=(blue_error-((blue_error*9+8)/16));
  443. X        ns-=step;
  444. X!       ns->red+=(red_error*3+8)/16;
  445. X!       ns->green+=(green_error*3+8)/16;
  446. X!       ns->blue+=(blue_error*3+8)/16;
  447. X        ns+=step;
  448. X!       ns->red+=(red_error*5+8)/16;
  449. X!       ns->green+=(green_error*5+8)/16;
  450. X!       ns->blue+=(blue_error*5+8)/16;
  451. X        ns+=step;
  452. X!       ns->red+=(red_error+8)/16;
  453. X!       ns->green+=(green_error+8)/16;
  454. X!       ns->blue+=(blue_error+8)/16;
  455. X      }
  456. X      odd_scanline=!odd_scanline;
  457. X    }
  458. X***************
  459. X*** 957,968 ****
  460. X    (void) free((char *) scanline);
  461. X    (void) free((char *) range_table);
  462. X    (void) free((char *) cache);
  463. X-   (void) free((char *) image->pixels);
  464. X-   image->packets=dithered_image->packets;
  465. X-   image->pixels=dithered_image->pixels;
  466. X-   dithered_image->file=(FILE *) NULL;
  467. X-   dithered_image->pixels=(RunlengthPacket *) NULL;
  468. X-   DestroyImage(dithered_image);
  469. X    return(False);
  470. X  }
  471. X  
  472. X--- 940,945 ----
  473. XCommon subdirectories: ImageMagick/scenes and ImageMagick2.2.2/scenes
  474. XCommon subdirectories: ImageMagick/utilities and ImageMagick2.2.2/utilities
  475. XCommon subdirectories: ImageMagick/xtp and ImageMagick2.2.2/xtp
  476. X-- 
  477. Xcristy@dupont.com
  478. X
  479. END_OF_FILE
  480.   if test 11479 -ne `wc -c <'fix-02'`; then
  481.     echo shar: \"'fix-02'\" unpacked with wrong size!
  482.   fi
  483.   # end of 'fix-02'
  484. fi
  485. echo shar: End of archive.
  486. exit 0
  487. exit 0 # Just in case...
  488.